package com.xxxx.mysql.dao;

import com.xxxx.mysql.model.WormLink;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface WormLinkMapper {
    @Delete({
        "delete from worm_link",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into worm_link (id, link_Name, ",
        "link_url, upper_level, ",
        "content, create_Time)",
        "values (#{id,jdbcType=INTEGER}, #{linkName,jdbcType=VARCHAR}, ",
        "#{linkUrl,jdbcType=VARCHAR}, #{upperLevel,jdbcType=VARCHAR}, ",
        "#{content,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP})"
    })
    int insert(WormLink record);

    @InsertProvider(type=WormLinkSqlProvider.class, method="insertSelective")
    int insertSelective(WormLink record);

//    @InsertProvider(type = WormLinkSqlProvider.class, method = "insertAllSelective")
//    void insertAllSelective(@Param("list") List<WormLinkSqlProvider> blacklists);

    @Select({
        "select",
        "id, link_Name, link_url, upper_level, content, create_Time",
        "from worm_link",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="link_Name", property="linkName", jdbcType=JdbcType.VARCHAR),
        @Result(column="link_url", property="linkUrl", jdbcType=JdbcType.VARCHAR),
        @Result(column="upper_level", property="upperLevel", jdbcType=JdbcType.VARCHAR),
        @Result(column="content", property="content", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_Time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
    })
    WormLink selectByPrimaryKey(Integer id);

    @UpdateProvider(type=WormLinkSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(WormLink record);

    @Update({
        "update worm_link",
        "set link_Name = #{linkName,jdbcType=VARCHAR},",
          "link_url = #{linkUrl,jdbcType=VARCHAR},",
          "upper_level = #{upperLevel,jdbcType=VARCHAR},",
          "content = #{content,jdbcType=VARCHAR},",
          "create_Time = #{createTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(WormLink record);
}